Cache based on project state not project.#77141
Merged
CyrusNajmabadi merged 22 commits intodotnet:mainfrom Feb 14, 2025
Merged
Conversation
CyrusNajmabadi
commented
Feb 10, 2025
| { | ||
| private HostAnalyzerInfo GetOrCreateHostAnalyzerInfo(Project project, ProjectAnalyzerInfo projectAnalyzerInfo) | ||
| private HostAnalyzerInfo GetOrCreateHostAnalyzerInfo( | ||
| SolutionState solution, ProjectState project, ProjectAnalyzerInfo projectAnalyzerInfo) |
Contributor
Author
There was a problem hiding this comment.
note: this follows the pattern of using 'solution/project' as the name of hte 'State' instance instead of 'solutionState/projectState'. We only use the latter if we have code that uses both at the same time.
CyrusNajmabadi
commented
Feb 10, 2025
| /// SolutionState has the data for Analyzers computed prior to Projects being added, and then never changes. | ||
| /// Practically, solution analyzers are the core Roslyn analyzers themselves we distribute, or analyzers shipped | ||
| /// by vsix (not nuget). These analyzers do not get loaded after changing *until* VS restarts. | ||
| /// </remarks> |
Contributor
Author
There was a problem hiding this comment.
subtle, but important point.
ToddGrun
reviewed
Feb 10, 2025
| /// next caller. | ||
| /// </summary> | ||
| private static readonly ConditionalWeakTable<Project, StrongBox<(ImmutableArray<DiagnosticAnalyzer> analyzers, CompilationWithAnalyzersPair? compilationWithAnalyzersPair)>> s_projectToCompilationWithAnalyzers = new(); | ||
| private static readonly ConditionalWeakTable<ProjectState, StrongBox<(ImmutableArray<DiagnosticAnalyzer> analyzers, CompilationWithAnalyzersPair? compilationWithAnalyzersPair)>> s_projectToCompilationWithAnalyzers = new(); |
Contributor
ToddGrun
reviewed
Feb 10, 2025
...r/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.CompilationManager.cs
Outdated
Show resolved
Hide resolved
ToddGrun
reviewed
Feb 10, 2025
...erver/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
Outdated
Show resolved
Hide resolved
ToddGrun
reviewed
Feb 10, 2025
| _projectToForceAnalysisData.TryAdd(project, box); | ||
| Contract.ThrowIfFalse(_projectToForceAnalysisData.TryGetValue(project, out box)); | ||
| _projectToForceAnalysisData.TryAdd(projectState, box); | ||
| Contract.ThrowIfFalse(_projectToForceAnalysisData.TryGetValue(projectState, out box)); |
Contributor
Contributor
Author
There was a problem hiding this comment.
Yeah. I didn't care much :-)
Contributor
Author
There was a problem hiding this comment.
Changed to only do this if we can't get the value.
ToddGrun
reviewed
Feb 13, 2025
|
|
||
| public async Task<ImmutableArray<DiagnosticData>> ForceAnalyzeProjectAsync(Project project, CancellationToken cancellationToken) | ||
| { | ||
| var projectState = project.State; |
Contributor
ToddGrun
reviewed
Feb 13, 2025
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetGenerators(System.String) | ||
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetGeneratorsForAllLanguages | ||
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetHashCode | ||
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.ToString |
Contributor
There was a problem hiding this comment.
Any idea what's up with this? I have this local change too.
Member
There was a problem hiding this comment.
ToString was added with the AnalyzerAssemblyRedirector API. Tomas has a PR to fix this up.
This was referenced Feb 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ensures that we only drop the info if the project (or any of its dependencies) change. It will not get dropped if docs/projects outside of its project-cone change.